package game.Enemty;

import game.MainPanel;

import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;

public class Monster2 {
    public int x,y,height,width;

    public int speed;//速度
    public Image enemyImg2;//用于画出来
    public Image[] enemyImgs2 = new Image[8];
    public int  direction=1;//怪物方向



    public Monster2(int x, int y,int height,int width){
        this.x=100;
        this.y=y;
        this.height=height;
        this.width=width;
        enemyImg2 = new ImageIcon("img/Monster/fly/fly1.png").getImage();
        for(int i=0;i<enemyImgs2.length;i++){
            enemyImgs2[i] = new ImageIcon("img/Monster/fly/fly"+i+".png").getImage();
        }
        this.speed=8;

    }


    int index = 5;
    public void moveAndStep2(){

        if(this.x>100&&direction==1){
            this.x -= this.speed;
            int i = index++;
            this.enemyImg2 = this.enemyImgs2[i];
            if(index==4){
                index=1;
            }
        }else if(this.x<800){
            direction=-1;
            this.x += this.speed;
            int i = index++;
            this.enemyImg2 = this.enemyImgs2[i];
            if(index==7){
                index=5;
            }
        }else if(this.x==800&&direction==-1){
            direction=1;
            index=1;
        }

    }




}
